﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Wintellect.PowerCollections;

namespace Ex1.School
{
    public class Student
    {
        private static Set<int> uniqueFacultyNumbers = new Set<int>();

        private string name;
        private int facultyNumber;

        public string Name
        {
            get { return name; }
            set 
            {
                if (value == null)
                {
                    throw new ArgumentNullException("Name cannot be null!");
                }
                if (value.Equals(""))
                {
                    throw new ArgumentException("Name cannot be empty!");
                }
                this.name = value;
            }
        }

        public int FacultyNumber
        {
            get { return facultyNumber; }
            set
            {
                if (value < 10000 || value > 99999)
                {
                    throw new ArgumentException("Faculty number is not valid 5 digit number!");
                }
                else if (uniqueFacultyNumbers.Contains(value))
                {
                    throw new ArgumentException("Faculty number is not unique in the system!");
                }
                else
                {
                    this.facultyNumber = value;
                    uniqueFacultyNumbers.Add(value);
                }
            }
        }

        public Student(string name, int facultyNumber)
        {
            this.Name = name;
            this.FacultyNumber = facultyNumber;
        }
    }
}
